//
//  LYLTabBarController.m
//  XCF
//
//  Created by dllo on 16/6/6.
//  Copyright © 2016年 GroupNine. All rights reserved.
//

#import "LYLTabBarController.h"
#import "LXKitchenMainViewController.h"
#import "YYFairMainViewController.h"
#import "LFBOtherMainViewController.h"
#import "SettingMainViewController.h"

@interface LYLTabBarController ()

@end

@implementation LYLTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UINavigationController *kitchenNav = [LXKitchenMainViewController defaultKitchenNavigationController];
    [self setupChildController:kitchenNav imageName:@"tabbar_kitchen_n" selectedImage:@"tabbar_kitchen_h"];
    [kitchenNav.tabBarItem setTitle:@"下厨房"];
    
    UINavigationController *fairNav = [YYFairMainViewController defaultFairNavigationController];
    [self setupChildController:fairNav imageName:@"tabbar_fair_n" selectedImage:@"tabbar_fair_h"];
    [fairNav.tabBarItem setTitle:@"市集"];
    
    UINavigationController *otherNav = [LFBOtherMainViewController defaultOtherNavigationController];
    [self setupChildController:otherNav imageName:@"tabbar_other_n" selectedImage:@"tabbar_other_h"];
    [otherNav.tabBarItem setTitle:@"待定"];
    
    UINavigationController *settingNav = [SettingMainViewController defaultSettingNavigationController];
    [self setupChildController:settingNav imageName:@"tabbar_setting_n" selectedImage:@"tabbar_setting_h"];
    [settingNav setTitle:@"设置"];
    
}

/**  绑定各个控制器, 顺便设置属性 */
- (void)setupChildController:(UIViewController *)vc imageName:(NSString *)imgName selectedImage:(NSString *)selectedImgName {
    
    // 设置图片间距
//    vc.tabBarItem.imageInsets = UIEdgeInsetsMake(2, 0, -8, 0);
    vc.tabBarItem.image = [[UIImage imageNamed:imgName] imageWithRenderingMode:1];
    
    // 设置图片的不渲染
    UIImage *image = [[UIImage imageNamed:selectedImgName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc.tabBarItem.selectedImage = image;
    
    [self addChildViewController:vc];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
